exports.__esModule = true;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.Service {
    constructor() {
        super();
        this.officeModel = this.db['office'];
    }

    newTask(data) {
        var _this = this;

        return _asyncToGenerator(function* () {
            data.id = think.uuid('v1');
            try {
                return yield _this.officeModel.create(data);
            } catch (error) {
                return _this.exceptionService.handleError(error);
            }
        })();
    }

    pendingTaskList(data) {
        var _this2 = this;

        return _asyncToGenerator(function* () {
            data.start = (parseInt(data.page) - 1) * parseInt(data.pageSize);
            let where = {
                type: data.type
            };

            try {
                return yield _this2.officeModel.findAndCountAll({
                    where: where,
                    limit: parseInt(data.pageSize),
                    offset: parseInt(data.start)
                });
            } catch (error) {
                return _this2.exceptionService.handleError(error);
            }
        })();
    }
};